
dat <- read.csv("c:/tappelhans/uni/marburg/lehre/2011/ws/r_course/referate/qc_single/hausaufgabe/dataset_single_qc.csv")
dat2 <- read.csv("c:/tappelhans/uni/marburg/lehre/2011/ws/r_course/presentations/07_file_handling/dataset_single_qc_orig.csv")
head(dat)

hist(dat2$t_wxt)
range(na.exclude(dat2$t_wxt))
bwplot(dat2$t_wxt)

hist(dat2$st_wxt)
range(na.exclude(dat2$st_wxt))

q1 <- quantile(dat$t_wxt, probs = c(0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99), 
               na.rm = T)
q2 <- quantile(dat2$t_wxt, probs = c(0.01, 0.05, 0.25, 0.5, 0.75, 0.95, 0.99), 
               na.rm = T)
q1
q2

sd1 <- sd(na.exclude(dat$t_wxt))
sd2 <- sd(na.exclude(dat2$t_wxt))
sd1
sd2

flag <- ifelse(dat2$t_wxt < x[[1]] | dat2$t_wxt > x[[length(x)]], "IM",
               ifelse(dat2$t_wxt < x[[2]] | dat2$t_wxt > x[[length(x) - 1]], "VU",
                      "OK"))

dat2$flag <- flag
problems <- subset(dat2, dat2$flag == "IM" | dat2$flag == "VU")

IM <- subset(dat2, dat2$flag == "IM")
VU <- subset(dat2, dat2$flag == "VU")

colour <- ifelse(flag == "IM", "red", ifelse(flag == "VU", "orange", "darkgreen"))

xyplot(dat2$t_wxt ~ as.POSIXct(dat2$dateEAT), #ylim = c(-20, 50),
       type = "p", pch = 16, col = colour)